package com.sykj.cloud.mq.demo.base;

import com.sykj.cloud.mq.demo.Constant;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import static com.sykj.cloud.mq.demo.Constant.*;
/**
 * @author Mr.will
 * @date 2021/3/4 10:38
 * @Desc 发送同步消息
 */
public class SyncProducer {


    public static void main(String[] args) throws Exception {
        DefaultMQProducer mqProducer=new DefaultMQProducer("group1");
        mqProducer.setNamesrvAddr(Constant.SERVER_URL);
        mqProducer.start();

        String body="奥利给,咦，苗子，RockerMQ";

        Message message=new Message(TOPIC_3,TAG_3,body.getBytes());

        SendResult sendResult = mqProducer.send(message);

        System.out.println(sendResult);


        mqProducer.shutdown();

    }


}
